home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_337 / cmanual / screens.lzh / Screens / Example6.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  157 lines

  1. /* Example6                                                              */
  2. /* This program will open a low-resolution, non-Interlaced, 4 colour     */
  3. /* Custom Screen. It will after 5 secondes start to change the screens   */
  4. /* colours, and will after a while close the screen and exit.            */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14. struct GfxBase *GfxBase;
  15.  
  16.  
  17. /* Declare a pointer to a Screen structure: */ 
  18. struct Screen *my_screen;
  19.  
  20. /* Declare and initialize your NewScreen structure: */
  21. struct NewScreen my_new_screen=
  22. {
  23.   0,            /* LeftEdge  Should always be 0. */
  24.   0,            /* TopEdge   Top of the display.*/
  25.   320,          /* Width     We are using a low-resolution screen. */
  26.   200,          /* Height    Non-Interlaced NTSC (American) display. */
  27.   2,            /* Depth     4 colours. */
  28.   0,            /* DetailPen Text should be drawn with colour reg. 0 */
  29.   1,            /* BlockPen  Blocks should be drawn with colour reg. 1 */
  30.   NULL,         /* ViewModes No special modes. (Low-res, Non-Interlaced) */
  31.   CUSTOMSCREEN, /* Type      Your own customized screen. */
  32.   NULL,         /* Font      Default font. */
  33.   "MY SCREEN",  /* Title     The screen' title. */
  34.   NULL,         /* Gadget    Must for the moment be NULL. */
  35.   NULL          /* BitMap    No special CustomBitMap. */
  36. };
  37.  
  38.  
  39.  
  40. main()
  41. {
  42.   /* Open the Intuition Library: */
  43.   IntuitionBase = (struct IntuitionBase *)
  44.     OpenLibrary( "intuition.library", 0 );
  45.   
  46.   if( IntuitionBase == NULL )
  47.     exit(); /* Could NOT open the Intuition Library! */
  48.   
  49.  
  50.  
  51.   /* Before we can use the function SetRGB4() we need to open the */
  52.   /* graphics Library. (See chapter 0 INTRODUCTION for more       */
  53.   /* information.)                                                */
  54.   GfxBase = (struct GfxBase *)
  55.     OpenLibrary( "graphics.library", 0);
  56.  
  57.   if( GfxBase == NULL )
  58.   {
  59.     /* Could NOT open the Graphics Library! */
  60.  
  61.     /* Close the Intuition Library since we have opened it: */
  62.     CloseLibrary( IntuitionBase );
  63.  
  64.     exit();
  65.   }
  66.  
  67.  
  68.  
  69.   /* We will now try to open the screen: */
  70.   my_screen = (struct Screen *) OpenScreen( &my_new_screen );
  71.   
  72.   /* The "(struct Screen *)" is not necessary but it tells the compiler */
  73.   /* that the function OpenScreen() returns a pointer to a Screen */
  74.   /* structure. (See chapter "Amiga C" for more information) */
  75.  
  76.   /* Have we opened the screen succesfully? */
  77.   if(my_screen == NULL)
  78.   {
  79.     /* Could NOT open the Screen! */
  80.     
  81.     /* Close the Graphics Library since we have opened it: */
  82.     CloseLibrary( GfxBase );
  83.  
  84.     /* Close the Intuition Library since we have opened it: */
  85.     CloseLibrary( IntuitionBase );
  86.  
  87.     exit();  
  88.   }
  89.  
  90.  
  91.  
  92.   /* We have opened the screen, and everything seems to be OK. */
  93.  
  94.   /* Wait for 5 seconds: */
  95.   Delay( 50 * 5);
  96.  
  97.  
  98.  
  99.   /* Change colour register 1 to red: */
  100.   SetRGB4( &my_screen->ViewPort, 1, 15, 0, 0 );  
  101.  
  102.   /* Wait for 1 second: */
  103.   Delay( 50 * 1);
  104.  
  105.  
  106.  
  107.   /* Change colour register 1 to green: */
  108.   SetRGB4( &my_screen->ViewPort, 1, 0, 15, 0 );  
  109.  
  110.   /* Wait for 1 second: */
  111.   Delay( 50 * 1);
  112.  
  113.  
  114.  
  115.   /* Change colour register 1 to blue: */
  116.   SetRGB4( &my_screen->ViewPort, 1, 0, 0, 15 );  
  117.  
  118.   /* Wait for 1 second: */
  119.   Delay( 50 * 1);
  120.  
  121.  
  122.  
  123.   /* Change colour register 1 to white: */
  124.   SetRGB4( &my_screen->ViewPort, 1, 15, 15, 15 );  
  125.  
  126.   /* Wait for 1 second: */
  127.   Delay( 50 * 1);
  128.  
  129.  
  130.  
  131.   /* Change colour register 0 to black: */
  132.   SetRGB4( &my_screen->ViewPort, 0, 0, 0, 0 );  
  133.  
  134.   /* Wait for 1 second: */
  135.   Delay( 50 * 1);
  136.  
  137.  
  138.  
  139.   /* Wait for 5 seconds: */
  140.   Delay( 50 * 5);
  141.  
  142.  
  143.  
  144.   /* We should always close the screens we have opened before we leave: */
  145.   CloseScreen( my_screen );
  146.  
  147.  
  148.  
  149.   /* Close the Graphics Library since we have opened it: */
  150.   CloseLibrary( GfxBase );
  151.  
  152.   /* Close the Intuition Library since we have opened it: */
  153.   CloseLibrary( IntuitionBase );
  154.  
  155.   /* THE END */
  156. }
  157.